package com.guigu.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

@RestController
@RefreshScope // 线上配置自动刷新
public class EchoController {

    // 注入线上配置
    @Value("${user.name}")
    private String name;

    @GetMapping(value = "/echo/{string}")
    public String echo(@PathVariable("string") String string) {
        return "server"+string+" online:"+name;
    }

    @GetMapping(value = "/echo1/{string}")
    public String echo1(@PathVariable("string") String string) throws InterruptedException {
        TimeUnit.MINUTES.sleep(1);
        int i = 1/0;
        return "server"+string+" online:"+name;
    }
}